package com.syedu.day03.homework;

import java.util.Scanner;

/**
 * description：最大公约数和最小公倍数
 * @author Administrator
 * @date 2022/3/8 16:34
 */
public class DivisorNumber {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请你输入两个数字: ");
        int n1 = scanner.nextInt();
        int n2 = scanner.nextInt();
        //把输入的n1和n2固定保存在两个变量中,供后面计算最小公倍数使用
        //int a1 = n1;
        //int a2 = n2;
        int temp = n1 % n2;
        while (temp != 0) {
            n1 = n2;
            n2 = temp;
            temp = n1 % n2;
        }
        System.out.println("最大公约数: " + n2);

        //公式:两个数字的乘积 = 它们的最大公约数 X 最小公倍数
        //System.out.println("最小公倍数: " + (a1 * a2) / n2);
    }
}